home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2011 November
/
CHIP_2011_11.iso
/
Programy
/
Inne
/
Gry
/
Carnage_Contest
/
scripts
/
CC Original
/
tools
/
Super Shaft.lua
< prev
next >
Wrap
Text File
|
2010-08-09
|
2KB
|
76 lines
--------------------------------------------------------------------------------
-- Super Shaft by Holzchopf
--------------------------------------------------------------------------------
-- setup
if cc==nil then cc={} end
cc.supershaft={}
-- load ressources
cc.supershaft.gfx_icn=loadgfx("weapons/supershaft.png") -- Weapon Image
setmidhandle(cc.supershaft.gfx_icn)
cc.supershaft.gfx_wpn=loadgfx("buildings/shaftpart.png") -- Weapon Image
setmidhandle(cc.supershaft.gfx_wpn)
cc.supershaft.sfx_build=loadsfx("crumble.ogg")
--------------------------------------------------------------------------------
-- Weapon
--------------------------------------------------------------------------------
cc.supershaft.id=addweapon("cc.supershaft","Super Shaft",cc.supershaft.gfx_icn,0)
cc.supershaft.ammo=1000
function cc.supershaft.draw() -- Draw
-- HUD Positioning
if weapon_shots==0 then
hudpositioning(pos_build,cc.supershaft.gfx_wpn,100,0,1)
end
end
function cc.supershaft.attack(attack)
-- start
if (weapon_mode==0) and (weapon_position==1) then
if weapon_x>getplayerx(0) then
weapon_mode=1
else
weapon_mode=-1
end
-- No more weapon switching!
useweapon(0)
-- Make sure that there is enough round time
secondsleft=math.floor(getframesleft()/50)
changeturntime(30-secondsleft)
end
-- Build (auto!)
if weapon_mode~=0 then
if weapon_timer>=10 then
weapon_timer=0
weapon_shots=weapon_shots+1
end
-- end if necessary
if (weapon_shots>=cc.supershaft.ammo) then
endturn()
else
-- place shaft part
if weapon_timer==0 then
-- check place
if collision(cc.supershaft.gfx_wpn,weapon_x,weapon_y,0,1)==0 and collision(cc.supershaft.gfx_wpn,weapon_x,weapon_y,1,0)==1 and weapon_x>0 and weapon_x<getmapwidth() then
scroll(weapon_x,weapon_y)
-- draw
terrainalphaimage(cc.supershaft.gfx_wpn,weapon_x,weapon_y)
-- effect
playsound(cc.supershaft.sfx_build)
for i=1,10,1 do
particle(p_fragment,weapon_x+math.random(-15,15),weapon_y+math.random(-12,12))
end
else
weapon_shots=cc.supershaft.ammo
end
end
-- draw
terrainrect(weapon_x-2-13*weapon_mode,weapon_y-13,3,25,0x00000000)
-- move
weapon_x=weapon_x+3*weapon_mode
weapon_timer=weapon_timer+1
end
end
end